import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class webDriverService {
        WebDriver driver = null;
    void createDriver()
    {
        //打开浏览器，用驱动来打开
        WebDriverManager.chromedriver().setup();
        //允许访问所有的链接
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");

        driver = new ChromeDriver(options);
        driver.get("https://www.baidu.com");
    }

    void test01() throws InterruptedException {
        createDriver();
        //
        driver.findElement(By.cssSelector("#kw")).sendKeys("哈利波特");
        driver.findElement(By.cssSelector("#su")).click();
        Thread.sleep(3000);

        driver.findElement(By.cssSelector("#kw")).clear();
        driver.findElement(By.cssSelector("#kw")).sendKeys("迪迦奥特曼");
        driver.findElement(By.cssSelector("#su")).click();
        Thread.sleep(3000);


        driver.quit();
    }
}
